Install PostgreSQL
2011/06/17 |
Install PostgreSQL for Database Server. |
[root@www ~]#
[root@www ~]# yum -y install postgresql-server /etc/rc.d/init.d/postgresql initdb Initializing database: [ OK ]
[root@www ~]#
vi /var/lib/pgsql/data/postgresql.conf # line 59: listen all listen_addresses = ' * '
# line 334: change log format log_line_prefix = ' %t %u %d '
/etc/rc.d/init.d/postgresql start Starting postgresql service: [ OK ]
[root@www ~]#
[root@www ~]# chkconfig postgresql on su - postgres # switch to postgres # set DB password for "postgres" -bash-4.1$ psql -c "alter user postgres with password 'password'" ALTER ROLE -bash-4.1$ createuser fermi # create DB user "fermi" Shall the new role be a superuser? (y/n) y # give privileges -bash-4.1$ su - fermi Password: [fermi@www ~]$ createdb testdb # create a test DB [fermi@www ~]$ psql -l # make sure List of databases Name | Owner | Encoding | Collation | Ctype | Access privileg es -----------+----------+----------+-------------+-------------+------------------ ----- postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres testdb | fermi | UTF8 | en_US.UTF-8 | en_US.UTF-8 | (4 rows)[fermi@www ~]$ psql testdb # connest to test DB
psql (8.4.7)
Type "help" for help. # set password testdb=# alter user fermi with password 'password'; ALTER ROLE # create a test table testdb=# create table test ( no int,name text ); CREATE TABLE # inset test datas testdb=# insert into test (no,name) values (1,'fermi'); INSERT 0 1 # confirm testdb=# select * from test;
no | name ----+------- 1 | fermi (1 row) # delete test table testdb=# drop table test; DROP TABLE # quit testdb=# \q dropdb testdb # delete test DB |